<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="renderer" content="webkit" />
		<meta name="robots" content="index, follow" />
		<title>提交报修单</title>
		<meta name="keywords" content="">
		<meta name="description" content="">
		<meta name="author" content="order by website" />
		<script type="text/javascript" src="__XIAOHE__/js/jquery.min.js"></script>
		<script type="text/javascript" src="__XIAOHE__/yuye/ajaxfileupload.js"></script>
		{include file="./index/public/share" /}
		<script src="__XIAOHE__/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
		 crossorigin="anonymous"></script>
		<script src="__XIAOHE__/js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="__XIAOHE__/css/bootstrap.min.css" media="screen" />
		<link rel="stylesheet" type="text/css" href="__XIAOHE__/css/style.css" />
		<link rel="stylesheet" type="text/css" href="__XIAOHE__/css/swiper.min.css" />


		<!-- 引入样式文件 -->
		<link rel="stylesheet" type="text/css" href="__XIAOHE__/yuye/index.css">
		<!-- 引入 Vue 和 Vant 的 JS 文件XiaoHe QQ496631085  -->
		<script src="__XIAOHE__/yuye/vue.min.js"></script>
		<script src="__XIAOHE__/yuye/vant.min.js"></script>
	</head>
	<body>
		<div class="row">
			<div class="col-xs-12" style="padding: 0;">
				<div class="Suggestions1" style="background-image: url(__XIAOHE__/images/Suggestions1.jpg);">
					<div class="Repair1">
						<div class="Repair1a">
							<img src="__XIAOHE__/images/Repair1.jpg" >
						</div>
						<div class="Repair1b">
							<input type="text" id="name" value="{$wxuser.name}"  placeholder="报修人员"/>
						</div>
					</div>
					
					<div class="Repair1">
						<div class="Repair1a">
							<img src="__XIAOHE__/images/Repair2.jpg" >
						</div>
						<div class="Repair1b">
							<input type="text" id="tel" value="{$wxuser.tel}" placeholder="联系电话"/>
						</div>
					</div>
					<div class="Repair1">
						<div class="Repair1a">
							<img src="__XIAOHE__/images/Repair3.jpg" >
						</div>
						<div class="Repair1b">
							<input type="text" id="ltdtel" value="{$wxuser.ltdtel}" placeholder="公司电话"/>
						</div>
					</div>
					<div class="Repair1">
						<div class="Repair1a">
							<img src="__XIAOHE__/images/Repair4.jpg" >
						</div>
						<div class="Repair1b">
							<input type="text" id="room" value="{$wxuser.room}" placeholder="房间号"/>
						</div>
					</div>
					<div class="Repair2">
						<div class="Repair1a">
							<img class="Repair1aimg" src="__XIAOHE__/images/Repair5.jpg" >报修内容
						</div>
						<div class="Repair1c">
							<textarea rows="" cols="" id="content" placeholder="例:窗户关不上"></textarea>
						</div>
					</div>

				
					<img class="img-responsive"  id="photoshow1" src="">
					<img class="img-responsive"  id="photoshow2" src="">
					<img class="img-responsive"  id="photoshow3" src="">
					<img class="img-responsive"  id="photoshow4" src="">
					<img class="img-responsive"  id="photoshow5" src="">
					<img class="img-responsive"  id="photoshow6" src="">
					<img class="img-responsive"  id="photoshow7" src="">
					<img class="img-responsive"  id="photoshow8" src="">
					<img class="img-responsive"  id="photoshow9" src="">
					

					<div class="Suggestions1e">
						<button id="photo" type="button">上传图片</button>
					</div>


					<div class="Suggestions1e">
						<button id="xiaohe" type="button">提交报修单</button>
					</div>


					<script type="text/javascript">
					// $('#photoshow').attr('src',serverId);
					// http://yywl.wxjoi.com/api/yuye/upload
						// var localIds = '';
						// var serverId = '';

					$('#photo').click(function(){

					
						//调用摄像头
						wx.chooseImage({
						  count: 9, // 默认9
						  sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
						  sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
						  success: function (res) {
						  var localIds = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
						  		// alert(localIds);
						  		arr=localIds
								for(var i=0;i<arr.length;i++)
								{
									shangwx(arr[i]);
								}

						  		// shangwx(localIds);

						  		// alert('upload end');
						  }
						});

						//预览图片接口
						wx.previewImage({
						  current: '', // 当前显示图片的http链接
						  urls: [] // 需要预览的图片http链接列表
						});
						//上传图片接口微信服务器
					})


					function shangwx(localIds) {
					
						wx.uploadImage({
						  localId: localIds.toString(), // 需要上传的图片的本地ID，由chooseImage接口获得
						  isShowProgressTips: 1, // 默认为1，显示进度提示
						  success: function (res) {
						    var serverId = res.serverId; // 返回图片的服务器端ID
						    httpget_upload(serverId);

						  }
						});
					}

					function httpget_upload(serverId2) {
						$.get("http://yywl.wxjoi.com/api/yuye/httpget_down/serverid/"+serverId2,  function(result){
						    if(result.code>0){
						    	for (var i = 1; i <= 9; i++) {
						    		if($("#photoshow"+i.toString()).attr('src').length > 0){
						    			continue;
						    		}else{
						    			$("#photoshow"+i.toString()).attr('src',result.msg);
						    			break;
						    		}
						    	}
						   

						    	// $('#photoshow').attr('src',result.msg);
						    	// $('#photo').hide();
						    	// alert(result.msg);
						    }else{
						    	alert('图片上传失败'+result.msg);
						    }
						});
						
					}
				






						

						$("#xiaohe").click(function(){
							var arr=new Array();
							// alert('tijiao');
							for (var i = 1; i <= 9; i++) {

								if($("#photoshow"+i.toString()).attr('src').length > 0){
					    			arr.push($("#photoshow"+i.toString()).attr('src'));//取得值为数组
									// alert($("#photoshow"+i.toString()).attr('src'));
					    		}else{
					    			break;
					    		}
							}
							arr = arr.join(',');//数组转成为字符串
						    $.post("/api/yuye/baoxiu",{
								name:$("#name").val(),
								tel:$("#tel").val(),
								ltdtel:$("#ltdtel").val(),
								room:$("#room").val(),
								content:$("#content").val(),
								images:arr,
							},function(data,status){
						        // alert("Data: " + data + "nStatus: " + status);
						        if(data.code>0){
						        	alert('提交成功');
						        	window.close();
						        }else{
						        	alert('提交失败：'+data.msg);
						        }
						    });
						});
					</script>

				</div>
			</div>
		</div>
	</body>
</html>
